﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraBars;

namespace TM.Common
{
    public static class DevExpressHelper
    {
        public static void AddBarButtonItemsIntoBarsubitem(
            this DevExpress.XtraBars.Ribbon.RibbonControl ribbon,
            DevExpress.XtraBars.BarSubItem Barsubitem,
            DevExpress.XtraBars.BarButtonItem[] buttons, int imageIndex = -1)
        {
            ribbon.Items.AddRange(buttons);
            foreach (var button in buttons)
            {
                if (imageIndex >= 0) button.ImageIndex = imageIndex;
                LinkPersistInfo linkPersistInfo = new LinkPersistInfo(button);
                Barsubitem.LinksPersistInfo.Add(linkPersistInfo);
            }
            ribbon.EndInit();
        }
    }
}
